<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [2, 6, 1, 7, 4]
        // 累加和num,先把数组的第一个数取出
        let num = 0
        for (let i = 0; i < arr.length; i++) {
            //循环累加，num加的是数组的值，不是下标

            num = num + arr[i]
        }
        let a = num / arr.length
        document.write(`累加和为${num},平均数为${a}`)
    </script>
</body>

</html>